// Default empty project template
import bb.cascades 1.0

// creates one page with a label

NavigationPane {
    id: navigationPane
    //    property alias
    // nghien cuu Qtime de lam viec giong theard
    Page {
        Container {
            background: Color.create("#ff0000ff")
            layout: StackLayout {
            }
            ActivityIndicator {
                id: busy
                visible: true
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
            }
            onCreationCompleted: {
                busy.start()
            }
            Label {
                id: myLabel
                objectName: "myLabel"
                text: qsTr("Hello World")
                textStyle {
                    color: Color.DarkRed
                    fontSizeValue: 13
                }
                //textStyle.base: SystemDefaults.TextStyles.BigText
                verticalAlignment: VerticalAlignment.Top
                horizontalAlignment: HorizontalAlignment.Center
            }
            TextField {
                id: masdsa
                hintText: "asdas"
                onTextChanging: {
                    myLabel.text = masdsa.text
                }
            }
            Container {
                verticalAlignment: VerticalAlignment.Bottom
                layout: AbsoluteLayout {
                }
                ImageView {
                    imageSource: "asset:///image/sun_cloud.png"
                    verticalAlignment: VerticalAlignment.Center
                }
            }
            Container {
                id: footer
                verticalAlignment: VerticalAlignment.Bottom
                layout: StackLayout {
                    orientation: LayoutOrientation.LeftToRight
                }
                Button {
                    text: "My Button"
                    onClicked: {
                        myLabel.text = "abc";
                        log("sdas");
                    }
                    //giong wieght trong android
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1
                    }
                    verticalAlignment: VerticalAlignment.Center
                }
                Button {
                    text: "My Button2"
                    onClicked: {
                        //myLabel.text = "abc2";
                        _app.changerText();
                    }
                    //giong wieght trong android
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1
                    }
                    verticalAlignment: VerticalAlignment.Center
                }
                Button {
                    text: "My Button3"
                    onClicked: {
                        //myLabel.text = "abc2";
                        _app.processFromQML();
                    }
                    //giong wieght trong android
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1
                    }
                    verticalAlignment: VerticalAlignment.Center
                }
                Button {
                    text: "Image"
                    imageSource: "asset:///image/sun_cloud.png"
                    onClicked: {
                        //myLabel.text = "abc2";
                        mParallelAnimation.play()
                    }
                    //giong wieght trong android
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1
                    }
                }
                Button {
                    text: "ShowPage2"
                    onClicked: {
                        //myLabel.text = "abc2";
                        showPage2();
                    }
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1
                    }
                }
                Button {
                    text: "asd"
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1
                    }
                }
            }
            ImageView {
                id: imageView
                imageSource: "asset:///image/sun_cloud.png"
                verticalAlignment: VerticalAlignment.Center
                animations: [
                    SequentialAnimation {
                        id: mParallelAnimation
                        animations: [
                            TranslateTransition {
                                fromX: 0
                                toX: 400
                                duration: 2000
                            },
                            FadeTransition {
                                fromOpacity: 255
                                toOpacity: 0
                                duration: 2000
                            }
                        ]
                    }
                ]
            }
        }
        function fromQML() {
            myLabel.text = "process from QML"
        }
    }
    function log(messeger) {
        _app.logFromQML(messeger);
    }
    function showPage2() {
        navigationPane.push(secondPage)
    }
    //    attachedObjects: [
    //        Page {
    //            id: page2
    //            Container {
    //                Label {
    //                    text: "Page2"
    //                    textStyle.fontSizeValue: 10
    //                    horizontalAlignment: HorizontalAlignment.Center
    //                    verticalAlignment: VerticalAlignment.Center
    //                }
    //            }
    //        }
    //    ]
    attachedObjects: [
        AboutScreen {
            id: secondPage
            onEmitSingal: {
                myLabel.text = s;
            }
        }
    ]
    //Luu y su dung Dynamic QML de control khoi tao page
}
